package add__8_HashSet;

import java.util.Objects;

public class Hashset2 {
    //重新hashCode 和 equals
    
    @Override
    public int hashCode() {
        return Objects.hash(name, num);
    }
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Hashset2 other = (Hashset2) obj;
        return Objects.equals(name, other.name) && num == other.num;
    }
    
    
    
    private String name;
    private int num;
    @Override
    public String toString() {
        return "Hashset2 [name=" + name + ", num=" + num + "]";
    }
    public Hashset2(String name, int i) {
        super();
        this.name = name;
        this.num = i;
    }
}
